<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2020/11/26
  Time: 10:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery.min.js"></script>
    <title>购物车</title>
    <script type="text/javascript">
        function delProducts() {
            $("#department-form").submit();
        }
        function search(){
            $("#aaa").submit();
        }
    </script>
</head>

<body>
<h1 class="text-center pt-3 pb-3">购物车</h1>

<div class="container">
    <div class="offset-md-2 col-md-8">
        <div class="row">
            <div class="col-md-10">
                <form class="form-inline" id="aaa" action="/all_products" method="post">
                    <div class="form-group">
                        <label>排序方式：</label>
                        <select class="form-control form-control-sm" name="order">
                            <option value="a" ${order=="a" ? "selected":""}>总价降序</option>
                            <option value="b" ${order=="b" ? "selected":""}>总价升序</option>
                            <option value="c" ${order=="c" ? "selected":""}>单价降序</option>
                            <option value="d" ${order=="d" ? "selected":""}>单价升序</option>
                        </select>
                        &nbsp;&nbsp;
                        <button type="button" onclick="search()" class="btn btn-sm btn-outline-secondary">排序</button>
                    </div>
                </form>
            </div>
            <div class="col-md-2">
                <form class="form-inline" action="/del_products" method="post">
                    <div class="form-group">
                        <button type="button" onclick="delProducts()" class="btn btn-sm btn-outline-secondary">批量删除</button>
                    </div>
                </form>
            </div>
        </div>

        <hr>

        <form  id="department-form" action="/del_products" method="post">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>选择</th>
                    <th>商品</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>总价</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>


                <c:forEach items="${products}" var="p">
                    <tr>
                        <td class="text-center">
                            <input type="checkbox" class="form-check-input" name="did" value="${p.productId}">
                        </td>
                        <td>${p.productName}</td>
                        <td>${p.price}</td>
                        <td>${p.number}</td>
                        <td>${p.sumprice}</td>
                        <td>
                            <a href="/goto_set_product?did=${p.productId}">修改数量</a> /

                        </td>
                    </tr>
                </c:forEach>

                <tr>
                    <td colspan="4" align="center">
                        总价
                    </td>
                    <td colspan="2">
                        ${products[0].allSumPrice}
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>
</body>
</html>
